/* ----------------------------------------------------------------------------------------------------------------------------------------------- /

Tile - 地图的tile
修改许可权限 - 江利峰

< --- Public Vars ------------------------------------------------------------------------------------------------------------------------------ >

< --- Public Functions ------------------------------------------------------------------------------------------------------------------------ >

※ 构造函数
public function Tile()

/ ----------------------------------------------------------------------------------------------------------------------------------------------- */
package editor.map.elements{
	import flash.display.Shape;
	import flash.display.Sprite;
	
	public class Tile extends Shape{
		
		/**
		 *tile的宽，目前是正方形 
		 */		
		public static const TILE_WIDTH:int = 16;
		
		public var lx:int;
		public var ly:int;
		private var _walkable:Boolean = true;
		
		// 构造函数
		public function Tile()
		{
		}

		/**
		 * 绘制tile外观 
		 */		
		public function draw(color:uint = 0xff0000):void
		{
			this.graphics.clear();
			
			graphics.beginFill(color, 0.4);
			graphics.lineStyle(1);
			graphics.drawRect(0,0,TILE_WIDTH,TILE_WIDTH);
			
			this.graphics.lineStyle(1,0xffff00, 0.6);
			this.graphics.moveTo(4,4);
			this.graphics.lineTo(TILE_WIDTH - 4, TILE_WIDTH - 4);
			this.graphics.moveTo(TILE_WIDTH - 4, 4);
			this.graphics.lineTo(4, TILE_WIDTH - 4);
			this.graphics.endFill();
			
			this.cacheAsBitmap = true;
		}
		
		public function get walkable():Boolean
		{
			return _walkable;
		}
		
		/**
		 * 是否可以行走
		 * @param value 
		 */		
		public function set walkable(value:Boolean):void
		{
			_walkable = value;
			draw();
		}
		// 
	}
}